<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
    <script>
        var socket;
        if (typeof(WebSocket) == "undefined") {
            console.log("您的浏览器不支持WebSocket");
        } else {
            console.log("您的浏览器支持WebSocket");
            socket = new WebSocket("ws://localhost:8080/web-socket-server/20");
            socket.onopen = function () {
                alert("socket.onopen");
            };
            socket.onmessage = function (msg) {
                alert("socket.onmessage");
            };
            socket.onclose = function () {
                alert("socket.onclose");
            };
            socket.onerror = function () {
                alert("socket.onerror");
            }
        }
    </script>
</head>
<body>
index.html
</body>
</html>